import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaLocaleProvider, WeaTable, WeaInputNumber, WeaCheckbox, WeaSearchGroup, WeaInput } from 'ecCom';


 class BlogEcme extends React.Component {
    constructor(props) {
        super(props);
        this.state = { searchGroupVisible: true, searchGroupPreviewVisible: true,
            hasLoad:false,
            isShowCube:true,
        };
        this.saveRef = ref => {
            this.refDom = ref;
        };
    }

    componentDidMount() {
        this.initCube()
    }
    //初始化建模
    initCube = () => {
        const cubeFiles = [
            `/spa/cube/static4engine/engine.js`,
            `/spa/cube/static4engine/engine.css`,
        ];
        const init = () => {
            this.setState((state, props) => ({ hasLoad: true }), () => {
                const { hasLoad } = this.state;
                if (hasLoad) {
                    const { EcmeBaseStore, CubeModeStore, CubeCommonStore } = (window.weaCubeEngine && window.weaCubeEngine.store) || {};
                    this.setState({
                        EcmeBaseStore,
                        CubeModeStore,
                        CubeCommonStore
                    })
                }
            });
        }
        loadjs.isDefined("bs_cube")
            ? loadjs.ready("bs_cube", init)
            : loadjs(cubeFiles, "bs_cube", init);
    }
    cubeCallback = (param) => {
        console.log(param)

    }
    render() {
        let cubeResourceType = "blog";
        let resourceid = "23";
        let EcmeSet = (window.weaCubeEngine && window.weaCubeEngine.com && window.weaCubeEngine.com.EcmeSet) || {};
        return (
            <div ref={this.saveRef}>
                {  this.state.hasLoad &&<EcmeSet query="blog" hideTop="1"  ispart="1" partType={cubeResourceType} partid={resourceid} callback={this.cubeCallback}/>}
            </div>
        );
    }
}


export default BlogEcme;